<?php
/**
 * Created by PhpStorm.
 * User: tanghui
 * Date: 2017/7/28
 * Time: 上午10:36
 */
class Controller_Seller_Public extends FController{

    function showMessage($message, $messageType = 'success', $jumpUrl = null){

    }

    //配送员的回调
    public function cbbdAction()
    {
        $reqData = @file_get_contents("php://input");
        FLogger::write("|{$reqData}|","ordercb");
        $orderModel = new FTable("orders",'','xhs_master');
        $reqObj=json_decode($reqData);
        $order_id= $reqObj->order_id;
        $ship_id= $reqObj->ship_id;
        $ship_status= $reqObj->order_status;
        $courier_name= $reqObj->courier_name;
        $courier_mobile= $reqObj->courier_mobile;

//        $order_id= FRequest::getPostString("order_id");
//        $ship_id= FRequest::getPostString("ship_id");
//        $ship_status= FRequest::getPostString("order_status");
//        $courier_name= FRequest::getPostString("courier_name");
//        $courier_mobile= FRequest::getPostString("courier_mobile");
        if($ship_status==3){
            $orderInfo = $orderModel->where(array('o_id'=>$order_id))->find();
            $diff=time()-strtotime($orderInfo['pay_time']);
            $makediff=$diff-$orderInfo['recv_expend'];
            $orderModel->update1(array('status'=>4,'make_expend'=>$makediff,'ship_status'=>$ship_status,'courier_name'=>$courier_name,'courier_mobile'=>$courier_mobile),array('o_id'=>$order_id));
        }else if($ship_status==4){
            $orderInfo = $orderModel->where(array('o_id'=>$order_id))->find();
            $diff=time()-strtotime($orderInfo['pay_time']);
            $senddiff=$diff-($orderInfo['recv_expend']+$orderInfo['make_expend']);
            $orderModel->update1(array('status'=>5,'complete_time'=>date('Y-m-d H:i:s'),'ship_status'=>$ship_status,'courier_name'=>$courier_name,'courier_mobile'=>$courier_mobile,'send_expend'=>$senddiff),array('o_id'=>$order_id));
        }else{
            $orderModel->update1(array('ship_status'=>$ship_status,'courier_name'=>$courier_name,'courier_mobile'=>$courier_mobile),array('o_id'=>$order_id));
        }
        echo 'success';
    }
}